<?php
//header("Content-type:text/html;charset=utf-8");  

namespace Admin\Controller;
use Think\Controller;
//namespace Admin\Controller;
use Think\Model;

class IndexController extends Controller 
{
  	public function index()
		{

			login('您好，请先登录');										//登录记录表		
			$sql=M('t_login_record')->find();			//登录用户的信息
			//dump($_SESSION['accounts']);die;
			$this->assign('User_Profile',$User_Profile);	//传递数组
			$this->assign('sql',$sql);
			$this->display();
		}

		/* 游戏用户信息 */
	public function grabble()
	{
		login('您好，请先登录');
		$t_users= M('','t_users','DB_CONFIG1'); 
		$map['account']=array('like','WX%');
		//玩家总数
		$count      = $t_users->where($map)->count();
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		$result = $t_users ->where($map)->limit($Page->firstRow.','.$Page->listRows)->order('create_time desc')->select();
		
		if(IS_GET)
		{
			$userid=$_GET['userid'];
			$name=$_GET['name'];
			$accounts=$_SESSION['accounts'];
			if($_GET['userid']!="" || $_GET['name']!="")
			{   
				$w['userid']=array('like','%'.$_GET['userid'].'%');												//把数据写到空数组去  
			    $w['name']=array('like','%'.$_GET['name'].'%');
			    $list      = $t_users->where($map)->where($w)->order('create_time desc')->select();

			    $count = count($list);
				$Page       = new \Org\Bjy\Page($count,100);
				$show       = $Page->show();
				if ($count > $Page->firstRow){
					$a = $Page->firstRow;
					if ($a>1){
						$b = $a+$Page->listRows;
					} else {
						$b = $Page->listRows;
					}
				} else {
					$Page->firstRow = 0;
					$a = 0;
					$b = $Page->listRows;
				}
				$result = array_slice($list,$a,$b-$a);
				//dump($count);die; 		
				// $Page       = new \Org\Bjy\Page($count,100);
				// $show       = $Page->show();
				// $result = $t_users ->where($map)->where($w)->limit($Page->firstRow.','.$Page->listRows)->order('create_time desc')->select();


				if($result)
				{
					$state=0;
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询游戏用户信息','$state')");
				}else
				{
					$state=1;
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询游戏用户信息','$state')");
				}
			}
			if($_GET['sdate']!="" && $_GET['edate']!="")
			{
				
				$sdate=$_GET['sdate'];
				$edate=$_GET['edate'];
				//dump($edate);die;
				$arr['create_time']=array('between',array($sdate,$edate));
			    $list    = $t_users->where($map)->where($arr)->order('create_time desc')->select();
			   
				$count = count($list);
				$Page       = new \Org\Bjy\Page($count,100);
				$show       = $Page->show();
				if ($count > $Page->firstRow){
					$a = $Page->firstRow;
					if ($a>1){
						$b = $a+$Page->listRows;
					} else {
						$b = $Page->listRows;
					}
				} else {
					$Page->firstRow = 0;
					$a = 0;
					$b = $Page->listRows;
				}
				$result = array_slice($list,$a,$b-$a);
                
				// $Page       = new \Org\Bjy\Page($count,100);
				// $show       = $Page->show();
				// $result = $t_users ->where($map)->where($arr)->order('create_time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				//dump($result);die;

				if($result)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询游戏用户信息','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询游戏用户信息','$state')");
				}
			}	
			if($_GET['sdate']!="" && $_GET['edate']!="" && $_GET['liucun'] != "")
			{
				$sdate=trim($_GET['sdate']);
				$edate=trim($_GET['edate']);
				$liucun=$_GET['liucun'];
				

				//搜索注册时间内在玩家注册后三天内有玩过至少一把游戏的玩家，调存储过程
				$list = M('','','DB_CONFIG1')->query("CALL sp_query_liucun_players('$sdate','$edate');");
				//dump($list);die;
				$counts = count($list);
				$Page       = new \Org\Bjy\Page($counts,100);
				$show       = $Page->show();
				if ($counts > $Page->firstRow){
					$a = $Page->firstRow;
					if ($a>1){
						$b = $a+$Page->listRows;
					} else {
						$b = $Page->listRows;
					}
				} else {
					$Page->firstRow = 0;
					$a = 0;
					$b = $Page->listRows;
				}
				$result = array_slice($list,$a,$b-$a);
				

				if($result)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询游戏用户信息','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询游戏用户信息','$state')");
				}
			}
		}
		
		$this->assign('liucun',$liucun);
		$this->assign('count',$count);
		$this->assign('counts',$counts);
		$this->assign('page',$show);
		$this->assign('result',$result);
		$this->display();
	}

		 /* 在线用户页面  */ 
	public function sinfo()
	{ 
	    login('您好，请先登录');
        if(IS_GET)
		{
			$userid  = ($_GET['userid']=="")?0:$_GET['userid'];
			$name    = ($_GET['name']=="")?'':$_GET['name'];
			$sdate   = trim(($_GET['sdate']=="")?'':$_GET['sdate']);
			$edate   = trim(($_GET['edate']=="")?'':$_GET['edate']);
			$cur_date = date('Y-m-d 00:00:00');
		    //$cur_date = date('2017-07-05 00:00:00');
			
			$str = "CALL sp_query_online_players('$cur_date',$userid,'$name','$sdate','$edate',0,0);";
			$count   = M('','','DB_CONFIG1')->query($str);

			$zaixian_users_sum  = count($count);
			$Page       = new \Org\Bjy\Page($zaixian_users_sum,100);
			$show       = $Page->show();
			if ($zaixian_users_sum > $Page->firstRow){
				$a = $Page->firstRow;
				if ($a>1){
					$b = $a+$Page->listRows;
				} else {
					$b = $Page->listRows;
				}
			} else {
				$Page->firstRow = 0;
				$a = 0;
				$b = $Page->listRows;
			}
			$result = array_slice($count,$a,$b-$a);
			

			if (!($userid == '' && $name == '' && $sdate == '' && $edate == '')){
				if($result)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询游戏用户信息','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询游戏用户信息','$state')");
				}
			}
		}
		
		$this->assign('zaixian_users_sum',$zaixian_users_sum);
		$this->assign('page',$show);
		$this->assign('result',$result);
		$this->display();
	}
	/*      修改密码           */
	public function modipass()
	{
				login('您好，请先登录');

			$t_agent= M('','t_agent','DB_CONFIG0'); 
			if(IS_POST)
			{
				if($_POST['password']=="" || $_POST['passwordd']=="")
				{
					error('密码不能为空');
				}
				if($_POST['password']!=$_POST['passwordd'])
				{
					error('您输入的新密码和确认密码不一致，请重新输入');
				}
				if(strlen($_POST['password'])<6)
				{
					error('请按照规范更改密码');
				}
				if(MD5($_POST['password'])==MD5($_POST['passwordd']))
				{
					$t_agent->password=MD5($_POST['password']);
					$new_password=$t_agent->where('userid='.$_SESSION['userid'])->save();
					if($new_password)
					{
						$state=0;
						$accounts=$_SESSION['accounts'];
						M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','更改用户密码','$state')");
					}else
					{
						$state=1;
						$accounts=$_SESSION['accounts'];
						M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','更改用户密码','$state')");
					}
					if($new_password)
					{
						login_error('密码重置成功，请保管好您的密码。');
					}
					else
					{
						error('系统繁忙，请您重再次输入');
					}
				}
			}
		$this->display();
	}
     /*   游戏提示管理  */
	public function prompt()
	{
		login('您好，请先登录');
		$t_message= M('','t_message','DB_CONFIG1');
	    $fkgmOne = $t_message->where("type= 'fkgm'")->find();
	    $noticeOne = $t_message->where("type= 'notice'")->find();
	    $loginOne = $t_message->where("type= 'login_notice'")->find();
		

        $this->assign('fkgmOne',$fkgmOne);
        $this->assign('noticeOne',$noticeOne);
        $this->assign('loginOne',$loginOne);
		$this->display();
	}
	  /*   提示修改  */
	public function tishi()
	{
		$t_message= M('','t_message','DB_CONFIG1');
	    $fkgmOne = $t_message->where("type= 'fkgm'")->find();
		if(IS_POST)
		{
			$prompt = $_POST['prompt'];
	        if ($fkgmOne =="") {
	        	M('','','DB_CONFIG1')->execute("insert into t_message(type,msg)values('fkgm','$prompt')");
	        }else{
	        	if (M('','','DB_CONFIG1')->execute("update t_message set msg='$prompt' where type='fkgm'")) {
	        		prompt('提示修改成功');
	        	}else{
	        		prompt('提示修改失败');
	        	}
	        }
	    }
	}
    /*   跑马灯修改  */
	public function Marquee()
	{
		
		$t_message= M('','t_message','DB_CONFIG1');
	    $noticeOne = $t_message->where("type= 'notice'")->find();
		if(IS_POST)
		{
			$Marquee = $_POST['Marquee'];
			
	        if ($noticeOne =="") {
	        	M('','','DB_CONFIG1')->execute("insert into t_message(type,msg)values('notice','$Marquee')");
	        }else{
	        	if (M('','','DB_CONFIG1')->execute("update t_message set msg='$Marquee' where type='notice'")) {
	        		prompt('跑马灯修改成功');
	        	}else{
	        		prompt('跑马灯修改失败');
	        	}
	        }
	    }
	}
	/*   登陆提示修改  */
	public function loginTs()
	{
		
		$t_message= M('','t_message','DB_CONFIG1');
	    $loginOne = $t_message->where("type= 'login_notice'")->find();
		if(IS_POST)
		{
			$loginTs = $_POST['loginTs'];
			
	        if ($loginOne =="") {
	        	M('','','DB_CONFIG1')->execute("insert into t_message(type,msg)values('login_notice','$loginTs')");
	        }else{
	        	if (M('','','DB_CONFIG1')->execute("update t_message set msg='$loginTs' where type='login_notice'")) {
	        		prompt('登陆提示修改成功');
	        	}else{
	        		prompt('登陆提示修改失败');
	        	}
	        }
	    }
	}
	/*   游戏历史记录  */
	public function loadgame()
	{
			login('您好，请先登录');
		$t_rooms= M('','t_each_round_history','DB_CONFIG1');
		//分页查询
		$sear['']=array();
		$count      = $t_rooms->where($w)->count();
		$Page       = new \Org\Bjy\Page($count,25);
		$show       = $Page->show();
		$loadgame = $t_rooms->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign('page',$show);	
		//传递数组   解析  json
		$list=$t_rooms->where('room_id='.I('get.room_id'))->select();
		$count = 0;
		$seats_setting=array();
		//$aa=array(banker_index=>$list)
		foreach ($list as $k=>$v)
		{
			$json=$v['history'];
			$obj=json_decode($json,true);
			$seats=$obj['seats'];
			$seats_setting[$count] = $seats;
			$count = $count +1;
		}
		foreach ($list as $ky=>$va)
		{
			$time[]=$va['begin_time'];
			
		}
	    //dump($time);die;
		$banker_index = array();
		for($i=0;$i<=$k;$i++){
			$banker_index[$i]=$list[$i]['banker_index'];
		}
		for($a=0;$a<count($seats_setting); $a++) {
			for($b=0;$b<count($seats_setting[$a]); $b++) {
				$seats_setting[$a][$b]["banker_index"]=$banker_index[$a];
				$seats_setting[$a][$b]["time"]=$time[$a];
			}
		}
			//dump($seats_setting);die;
		$this->assign('seats_setting',$seats_setting);
		$this->assign('list',$list);
		$this->display();
	}
	//游戏记录
	public function history()
	{
		login('您好，请先登录');
		$count = M('','','DB_CONFIG1')->query("select room_id,max(round_no) from t_each_round_history group by room_id");
		$counts = count($count);
		
		$Page       = new \Org\Bjy\Page($counts,100);
		$show       = $Page->show();
		$a = $Page->firstRow;
		$b = $Page->listRows;
		$list = M('','','DB_CONFIG1')->query("select room_id,max(round_no) round_no,userid1,userid2,userid3,userid4,min(begin_time) begin_time,max(end_time) end_time from t_each_round_history group by room_id order by begin_time desc limit $a,$b");
		//dump($list);die;
		
		if(IS_GET)
		{
			
			if($_GET['room_id']!="" || $_GET['users']!="")
			{
				
				$wanjia  = ($_GET['users']=="")?'':$_GET['users'];
			 	$room_id = ($_GET['room_id']=="")?'':$_GET['room_id'];
				
				$count = M('','','DB_CONFIG1')->query("select room_id,max(round_no) round_no,userid1,userid2,userid3,userid4,min(begin_time) begin_time,max(end_time) end_time from t_each_round_history  where room_id like '%$room_id%' and (userid1 like '%$wanjia%' or userid2 like '%$wanjia%'  or userid3 like '%$wanjia%' or userid4 like '%$wanjia%') group by room_id order by begin_time desc");
				//dump($count);die;
		        $counts = count($count);
                $Page       = new \Org\Bjy\Page(count($count),100);
				$show       = $Page->show();
				
				if ($counts > $Page->firstRow){
					$a = $Page->firstRow;
					if ($a>1){
							$b = $a+$Page->listRows;
						} else {
							$b = $Page->listRows;
					}
				} else {
					$Page->firstRow = 0;
					$a = 0;
					$b = $Page->listRows;
				}

				$list = array_slice($count,$a,$b-$a);
				
				if($list)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}
			}
			if($_GET['users']!="" && $_GET['sdate']!="" && $_GET['edate']!="")
			{
				$sdate=trim($_GET['sdate']); 
				$edate=trim($_GET['edate']);
				$wanjia  = $_GET['users'];	
				
				$count = M('','','DB_CONFIG1')->query("select room_id,max(round_no) round_no,userid1,userid2,userid3,userid4,min(begin_time) begin_time,max(end_time) end_time from t_each_round_history where begin_time between  '$sdate' and '$edate' and userid1 like '%$wanjia%' or userid2 like '%$wanjia%'  or userid3 like '%$wanjia%' or userid4 like '%$wanjia%' group by room_id order by begin_time desc");
				//dump($count);die;
				$counts = count($count);
				
				$Page       = new \Org\Bjy\Page($counts,100);
				$show       = $Page->show();
				if ($counts > $Page->firstRow){
					$a = $Page->firstRow;
					if ($a>1){
							$b = $a+$Page->listRows;
						} else {
							$b = $Page->listRows;
					}
				} else {
					$Page->firstRow = 0;
					$a = 0;
					$b = $Page->listRows;
				}

				$list = array_slice($count,$a,$b-$a);
				
				foreach ($count as $key => $value) {
					$add[] = $value['round_no'];
				}
				$bureaus = array_sum($add);
				//dump($acc);die;
				if($list)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}
			}

			if($_GET['sdate']!="" && $_GET['edate']!="" && $_GET['users']=="")
			{
				$sdate=trim($_GET['sdate']); 
				$edate=trim($_GET['edate']);
				$count = M('','','DB_CONFIG1')->query("select room_id,max(round_no) round_no,userid1,userid2,userid3,userid4,min(begin_time) begin_time,max(end_time) end_time from t_each_round_history where begin_time between '$sdate' and '$edate' group by room_id order by begin_time desc");
				//dump($count);die;
				$counts = count($count);
				
				$Page       = new \Org\Bjy\Page($counts,100);
				$show       = $Page->show();
				if ($counts > $Page->firstRow){
					$a = $Page->firstRow;
					if ($a>1){
							$b = $a+$Page->listRows;
						} else {
							$b = $Page->listRows;
					}
				} else {
					$Page->firstRow = 0;
					$a = 0;
					$b = $Page->listRows;
				}

				$list = array_slice($count,$a,$b-$a);
				
				if($list)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}
			}

			
		}
		$this->assign('bureaus',$bureaus);
		$this->assign('rooms',$rooms);
		$this->assign('page',$show);
		$this->assign('list',$list);
		$this->display();
	}
			/* 转账给游戏玩家记录 */
	public function playercharge()
	{
		login('您好，请先登录');
		$t_agent_add_cards_to_user= M('','t_agent_add_cards_to_user','DB_CONFIG0');
		//$t_users= M('','t_users','DB_CONFIG1');
		 
		$w=array();
		$count      = $t_agent_add_cards_to_user->where($w)->count();
		//dump($count);die;
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		$loadgame = $t_agent_add_cards_to_user->where($w)->order('regtime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			
		
		//$userid=$_GET['userid'];
		if(IS_GET)
		{
			
			if($_GET['userid']!="" || $_GET['name']!="" || $_GET['daili']!="")
			{   
				$userid=$_GET['userid'];
			    $name=$_GET['name'];
			    $daili=$_GET['daili'];
				$w['recipient']=array('like','%'.$userid.'%');//把数据写到空数组去  
				$w['name']=array('like','%'.$name.'%');//把数据写到空数组
				$w['benefactor']=array('like','%'.$daili.'%');//把数据写到空数组
				$count      = $t_agent_add_cards_to_user->where($w)->count();
				$Page       = new \Org\Bjy\Page($count,100);
				$show       = $Page->show();				
				$loadgame=$t_agent_add_cards_to_user->where($w)->limit($Page->firstRow.','.$Page->listRows)->select();

				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}
			}	
			if($_GET['sdate']!="" || $_GET['edate']!="")
			{
				$sdate=$_GET['sdate']; //get来的时间转为时间戳
				$edate=$_GET['edate'];	//get来的时间转为时间戳
				$arr['regtime']=array('between',array($sdate,$edate));
				$count      = $t_agent_add_cards_to_user->where($arr)->count();
				$Page       = new \Org\Bjy\Page($count,100);
				$show       = $Page->show();
				$loadgame=$t_agent_add_cards_to_user->where($arr)->limit($Page->firstRow.','.$Page->listRows)->select();//时间不符合    需要修正！！！！
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}
			}
		}
		$this->assign('page',$show);
		$this->assign('loadgame',$loadgame);
		$this->display();
	}

			/* 玩家微信充值记录 */
	public function playerRecharge()
	{
		login('您好，请先登录');
		$t_order= M('','t_orders','DB_CONFIG1');
		//$t_users= M('','t_users','DB_CONFIG1');
		 
		$w=array();
		$count      = $t_order->count();
		
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		$a = $Page->firstRow;
		$b = $Page->listRows;
		
		$loadgame = M('','','DB_CONFIG1')->query("SELECT a.*,b.* FROM t_orders AS a LEFT JOIN t_users AS b ON a.userid = b.userid ORDER BY a.updateTime DESC limit $a,$b");
		
		if(IS_GET)
		{
			
			if($_GET['userid']!="" || $_GET['name']!="" || $_GET['sdcustomno']!="" || $_GET['type']!="" || $_GET['payment']!="" || $_GET['state']!="")
			{   
				$userid=($_GET['userid'] =="")?"":$_GET['userid'];
			    $name=($_GET['name'] =="")?"":$_GET['name'];
			    $sdcustomno=($_GET['sdcustomno'] =="")?"":$_GET['sdcustomno'];
			    $type=($_GET['type'] =="")?"":$_GET['type'];
			    $payment=($_GET['payment'] =="")?"":$_GET['payment'];
			    $czstate=($_GET['state'] =="")?"":$_GET['state'];
			    //dump($state);die;
			    //dump($userid);dump($name);dump($sdcustomno);die;
				$list      = M('','','DB_CONFIG1')->query("SELECT a.*,b.* FROM t_orders AS a LEFT JOIN t_users AS b ON a.userid = b.userid WHERE a.userid LIKE '%".$userid."%' AND b.name LIKE '%".$name."%' AND a.sdcustomno LIKE '%".$sdcustomno."%' AND a.type LIKE '%".$type."%' AND a.payment LIKE '%".$payment."%' AND a.state LIKE '%".$czstate."%' ORDER BY a.updateTime DESC");
				//dump($list);die;
				$count = count($list);
				$Page       = new \Org\Bjy\Page($count,100);
				$show       = $Page->show();
				if ($count > $Page->firstRow){
					$a = $Page->firstRow;
					if ($a>1){
							$b = $a+$Page->listRows;
						} else {
							$b = $Page->listRows;
					}
				} else {
					$Page->firstRow = 0;
					$a = 0;
					$b = $Page->listRows;
				}
				$loadgame = array_slice($list,$a,$b-$a);

				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}
				else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}
			}
					
			if($_GET['sdate']!="" || $_GET['edate']!="")
			{
				$sdate=$_GET['sdate']; //get来的时间转为时间戳
				$edate=$_GET['edate'];	//get来的时间转为时间戳
				
				$list      = M('','','DB_CONFIG1')->query("SELECT a.*,b.* FROM t_orders AS a LEFT JOIN t_users AS b ON a.userid = b.userid WHERE a.updateTime >='$sdate' and a.updateTime <='$edate' ORDER BY a.updateTime DESC");
				//dump($list);die;
				$count = count($list);
				$Page       = new \Org\Bjy\Page($count,100);
				$show       = $Page->show();
				if ($count > $Page->firstRow){
					$a = $Page->firstRow;
					if ($a>1){
							$b = $a+$Page->listRows;
						} else {
							$b = $Page->listRows;
					}
				} else {
					$Page->firstRow = 0;
					$a = 0;
					$b = $Page->listRows;
				}
				$loadgame = array_slice($list,$a,$b-$a);    
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','给玩家冲钻信息查询','$state')");
				}
			}
		}
		
		$this->assign('type',$type);
		$this->assign('payment',$payment);
		$this->assign('czstate',$czstate);
		$this->assign('page',$show);
		$this->assign('loadgame',$loadgame);
		$this->display();
	}
				/* 充值信息记录 订单成功*/
	public function recharge()
	{
		login('您好，请先登录');
		$yp_apply_order= M('','yp_apply_order','DB_CONFIG0');
		
		$count      = $yp_apply_order->where('order_status=1')->count();
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		$loadgame = $yp_apply_order->order('times desc')->where('order_status=1')->limit($Page->firstRow.','.$Page->listRows)->select();
		//dump($loadgame);die;
		
				
		if(IS_GET)
		{
			if($_GET['userid']!="" || $_GET['order_no']!="")
			{
				$w['oper_account']=array('like','%'.$_GET['userid'].'%');//id 查询
				$w['order_no']=array('like','%'.$_GET['order_no'].'%');//订单号查询
				$count  = $yp_apply_order->where($w)->where('order_status=1')->count();
				//dump($count);die;
				$Page     = new \Org\Bjy\Page($count,1000);
		        $show     = $Page->show();
				$loadgame=$yp_apply_order->where($w)->where('order_status=1')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
							
			if($_GET['sdate']!="" || $_GET['edate']!="")
			{
				$arr['times']=array('between',array($_GET['sdate'],$_GET['edate']));
				$count  = $yp_apply_order->where($arr)->where('order_status=1')->count();
				//dump($count);die;
				$Page     = new \Org\Bjy\Page($count,1000);
		        $show     = $Page->show(); 
				$loadgame=M('yp_apply_order')->where($arr)->where('order_status=1')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();	
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
			
			// if($_GET['rmb']!="")
			// {
			// 	if($_GET['rmb']==1)
			// 	{   
			// 		$get_select = "40元";
			// 		$count  = $yp_apply_order->where($arr)->where('order_gems=100 and order_status=1')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=100 and order_status=1')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();

			// 	}
			// 	if($_GET['rmb']==2)
			// 	{   
			// 		$post_select = "110元";
			// 		$count  = $yp_apply_order->where($arr)->where('order_gems=300 and order_status=1')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=300 and order_status=1')->order('times desc')->
			// 		          limit($Page->firstRow.','.$Page->listRows)->select();	
			// 	}
			// 	if($_GET['rmb']==3)
			// 	{   
			// 		$post_select = "350元";
			// 		$count  = $yp_apply_order->where($arr)->where('order_gems=1000 and order_status=1')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=1000 and order_status=1')->order('times desc')->
			// 		          limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// 	if($_GET['rmb']==4)
			// 	{   
			// 		$post_select = "1000元";
			// 		$count  = $yp_apply_order->where($arr)->where('order_gems=3000 and order_status=1')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=3000 and order_status=1')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// 	if($_GET['rmb']==5)
			// 	{   
			// 		$post_select = "3000元";
			// 		$count  = $yp_apply_order->where($arr)->where('order_gems=10000 and order_status=1')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=10000 and order_status=1')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// }
		}
		//dump($post_select);die;
		$this->assign('page',$show);
		$this->assign('post_select',$post_select);
		$this->assign('loadgame',$loadgame);
		$this->display();
	}
				/* 充值信息记录 所有订单*/
	public function recharge00()
	{
		login('您好，请先登录');
		$yp_apply_order= M('','yp_apply_order','DB_CONFIG0');
		
		$count      = $yp_apply_order->count();
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		$loadgame = $yp_apply_order->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		//dump($loadgame);die;
		
				
		if(IS_GET)
		{//id 查询
			if($_GET['userid']!="")
			{
				$w['oper_account']=array('like','%'.I('get.userid').'%');//把数据写到空数组去  
				$count      = $yp_apply_order->where($w)->count();
				$Page       = new \Org\Bjy\Page($count,1000);
				$show       = $Page->show();
				$loadgame=$yp_apply_order->where($w)->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
			
			//订单号查询
			if($_GET['order_no']!="")
			{
				$w['order_no']=array('like','%'.I('get.order_no').'%');//把数据写到空数组去
				$count      = $yp_apply_order->where($w)->count();
				$Page       = new \Org\Bjy\Page($count,1000);
				$show       = $Page->show();  
				$loadgame=$yp_apply_order->where($w)->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}				
			if($_GET['sdate']!="" || $_GET['edate']!="")
			{
				$arr['times']=array('between',array($_GET['sdate'],$_GET['edate']));
				$count      = $yp_apply_order->where($arr)->count();
				$Page       = new \Org\Bjy\Page($count,1000);
				$show       = $Page->show(); 
				$loadgame=M('yp_apply_order')->where($arr)->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();	
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
			
			// if($_GET['rmb']!="")
			// {
			// 	if($_GET['rmb']==1)
			// 	{   
			// 		$post_select = "40元";
			// 		$count  = $yp_apply_order->where('order_gems=100')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=100')->order('times desc')->
			// 		          limit($Page->firstRow.','.$Page->listRows)->select();

			// 	}
			// 	if($_GET['rmb']==2)
			// 	{   
			// 		$post_select = "110元";
			// 		$count  = $yp_apply_order->where('order_gems=300')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=300')->order('times desc')->
			// 		          limit($Page->firstRow.','.$Page->listRows)->select();	
			// 	}
			// 	if($_GET['rmb']==3)
			// 	{   
			// 		$post_select = "350元";
			// 		$count  = $yp_apply_order->where('order_gems=1000')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=1000')->order('times desc')->
			// 		          limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// 	if($_GET['rmb']==4)
			// 	{   
			// 		$post_select = "1000元";
			// 		$count  = $yp_apply_order->where('order_gems=3000')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=3000')->order('times desc')->
			// 		          limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// 	if($_GET['rmb']==5)
			// 	{   
			// 		$post_select = "3000元";
			// 		$count  = $yp_apply_order->where('order_gems=10000')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=10000')->order('times desc')->
			// 		          limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// }
		}
		//dump($post_select);die;
		$this->assign('page',$show);
		$this->assign('post_select',$post_select);
		$this->assign('loadgame',$loadgame);
		$this->display();
	}
             /* 充值信息记录 订单异常*/
	public function recharge02()
	{
		login('您好，请先登录');
		$yp_apply_order= M('','yp_apply_order','DB_CONFIG0');
		
		$count      = $yp_apply_order->where('order_status=0')->count();
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		$loadgame = $yp_apply_order->order('times desc')->where('order_status=0')->limit($Page->firstRow.','.$Page->listRows)->select();
		//dump($loadgame);die;
		
				
		if(IS_GET)
		{//id 查询
			if($_GET['userid']!="")
			{
				$w['oper_account']=array('like','%'.I('get.userid').'%');//把数据写到空数组去 
				$count      = $yp_apply_order->where($w)->where('order_status=0')->count();
				$Page       = new \Org\Bjy\Page($count,1000);
				$show       = $Page->show(); 
				$loadgame=$yp_apply_order->where($w)->where('order_status=0')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
			//订单号查询
			if($_GET['order_no']!="")
			{
				$w['order_no']=array('like','%'.I('get.order_no').'%');//把数据写到空数组去 
				$count      = $yp_apply_order->where($w)->where('order_status=0')->count();
				$Page       = new \Org\Bjy\Page($count,1000);
				$show       = $Page->show();  
				$loadgame=$yp_apply_order->where($w)->where('order_status=0')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}				
			if($_GET['sdate']!="" || $_GET['edate']!="")
			{
				$arr['times']=array('between',array($_GET['sdate'],$_GET['edate']));
				$count      = $yp_apply_order->where($arr)->where('order_status=0')->count();
				$Page       = new \Org\Bjy\Page($count,1000);
				$show       = $Page->show();
				$loadgame=M('yp_apply_order')->where($arr)->where('order_status=0')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();	
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
			
			// if($_GET['rmb']!="")
			// {
			// 	if($_GET['rmb']==1)
			// 	{   
			// 		$post_select = "40元";
			// 		$count  = $yp_apply_order->where('order_gems=100 and order_status=0')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=100 and order_status=0')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();

			// 	}
			// 	if($_GET['rmb']==2)
			// 	{   
			// 		$post_select = "110元";
			// 		$count  = $yp_apply_order->where('order_gems=300 and order_status=0')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=300 and order_status=0')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();	
			// 	}
			// 	if($_GET['rmb']==3)
			// 	{   
			// 		$post_select = "350元";
			// 		$count  = $yp_apply_order->where('order_gems=1000 and order_status=0')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=1000 and order_status=0')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// 	if($_GET['rmb']==4)
			// 	{   
			// 		$post_select = "1000元";
			// 		$count  = $yp_apply_order->where('order_gems=3000 and order_status=0')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=3000 and order_status=0')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// 	if($_GET['rmb']==5)
			// 	{   
			// 		$post_select = "3000元";
			// 		$count  = $yp_apply_order->where('order_gems=10000 and order_status=0')->count();
			// 		//dump($count);die;
			// 		$Page     = new \Org\Bjy\Page($count,1000);
			//         $show     = $Page->show(); 
			// 		$loadgame=M('yp_apply_order')->where('order_gems=10000 and order_status=0')->order('times desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			// 	}				
			// }
		}
		//dump($post_select);die;
		$this->assign('page',$show);
		$this->assign('post_select',$post_select);
		$this->assign('loadgame',$loadgame);
		$this->display();
	}
              /* 充值信息记录 订单处理中*/
	// public function recharge03()
	// {
	// 	login('您好，请先登录');
	// 	$yp_apply_order= M('','yp_apply_order','DB_CONFIG0');
		
	// 	$count      = $yp_apply_order->where('order_status=2')->count();
	// 	$Page       = new \Org\Bjy\Page($count,15);
	// 	$show       = $Page->show();
	// 	$loadgame = $yp_apply_order->order('times desc')->where('order_status=2')->limit($Page->firstRow.','.$Page->listRows)->select();
	// 	//dump($loadgame);die;
		
				
	// 	if(IS_GET)
	// 	{//id 查询
	// 		if($_GET['userid']!="")
	// 		{
	// 			$w['oper_account']=array('like','%'.I('get.userid').'%');//把数据写到空数组去  
	// 			$loadgame=$yp_apply_order->where($w)->where('order_status=2')->select();
	// 			if($loadgame)
	// 			{
	// 				$state=0;
	// 				$accounts=$_SESSION['accounts'];
	// 				M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
	// 			}else
	// 			{
	// 				$state=1;
	// 				$accounts=$_SESSION['accounts'];
	// 				M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
	// 			}
	// 		}
	// 		//订单号查询
	// 		if($_GET['order_no']!="")
	// 		{
	// 			$w['order_no']=array('like','%'.I('get.order_no').'%');//把数据写到空数组去  
	// 			$loadgame=$yp_apply_order->where($w)->where('order_status=2')->select();
	// 			if($loadgame)
	// 			{
	// 				$state=0;
	// 				$accounts=$_SESSION['accounts'];
	// 				M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
	// 			}else
	// 			{
	// 				$state=1;
	// 				$accounts=$_SESSION['accounts'];
	// 				M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
	// 			}
	// 		}				
	// 		if($_GET['sdate']!="" || $_GET['edate']!="")
	// 		{
	// 			$arr['times']=array('between',array($_GET['sdate'],$_GET['edate']));
	// 			$loadgame=M('yp_apply_order')->where($arr)->where('order_status=2')->select();	
	// 			if($loadgame)
	// 			{
	// 				$state=0;
	// 				$accounts=$_SESSION['accounts'];
	// 				M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
	// 			}else
	// 			{
	// 				$state=1;
	// 				$accounts=$_SESSION['accounts'];
	// 				M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
	// 			}
	// 		}
			
	// 		if($_GET['rmb']!="")
	// 		{
	// 			if($_GET['rmb']==1)
	// 			{   
	// 				$post_select = "40元";
	// 				$loadgame=M('yp_apply_order')->where('order_gems=100 and order_status=2')->select();

	// 			}
	// 			if($_GET['rmb']==2)
	// 			{   
	// 				$post_select = "110元";
	// 				$loadgame=M('yp_apply_order')->where('order_gems=300 and order_status=2')->select();
	// 			}
	// 			if($_GET['rmb']==3)
	// 			{   
	// 				$post_select = "350元";
	// 				$loadgame=M('yp_apply_order')->where('order_gems=1000 and order_status=2')->select();
	// 			}				
	// 			if($_GET['rmb']==4)
	// 			{   
	// 				$post_select = "1000元";
	// 				$loadgame=M('yp_apply_order')->where('order_gems=3000 and order_status=2')->select();
	// 			}				
	// 			if($_GET['rmb']==5)
	// 			{   
	// 				$post_select = "3000元";
	// 				$loadgame=M('yp_apply_order')->where('order_gems=10000 and order_status=2')->select();
	// 			}				
	// 		}
	// 	}
	// 	$this->assign('page',$show);
	// 	$this->assign('post_select',$post_select);
	// 	$this->assign('loadgame',$loadgame);
	// 	$this->display();
	// }
	/*  当天活跃玩家       */
	public function active_player()
	{
	    login('您好，请先登录');
		$sdate       = date("Y-m-d 00:00:00",strtotime("-1 day"));
		$edate       = date("Y-m-d 00:00:00");
		// $arr1['record_time']=array('between',array($sdate,$edate));
		
		$count = M("","","DB_CONFIG1")->query("select userid,max(record_time) record_time from t_user_everyday_record where record_time between '$sdate' and '$edate' group by userid order by max(record_time) desc");
	 	//dump($count);die;
		$counts = count($count);
		$Page       = new \Org\Bjy\Page($counts,100);
		$show       = $Page->show();
		$a = $Page->firstRow;
		$b = $Page->listRows;
		$deputy = M("","","DB_CONFIG1")->query("select userid,max(record_time) record_time,name,gems,cost_gems,game_round,recharge_gems,cost_time  from t_user_everyday_record where record_time between '$sdate' and '$edate' group by userid order by max(record_time) desc limit $a,$b");


		if(IS_GET)
		{
			if($_GET['userid']!="" || $_GET['name']!="" AND $_GET['sdate']=="")
			{
				$w['userid']=array('like','%'.$_GET['userid'].'%');//把数据写到空数组去  
				$w['name']=array('like','%'.$_GET['name'].'%');//把数据写到空数组去  
				$count = M("","","DB_CONFIG1")->query("select userid,max(record_time) record_time from t_user_everyday_record where userid like '%".$_GET['userid']."%' and name like '%".$_GET['name']."%' group by userid order by max(record_time) desc");
				
				$counts = count($count);
				$Page       = new \Org\Bjy\Page($counts,100);
				$show       = $Page->show();
				$a = $Page->firstRow;
		        $b = $Page->listRows;
				
				$deputy = M("","","DB_CONFIG1")->query("select userid,max(record_time) record_time,name,gems,cost_gems,game_round,recharge_gems,cost_time  from t_user_everyday_record where userid like '%".$_GET['userid']."%' and name like '%".$_GET['name']."%' group by userid order by max(record_time) desc limit $a,$b");
				
				if($deputy)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}	
			if($_GET['userid']=="" AND $_GET['name']=="" AND $_GET['sdate']!="" )
			{
				$sdate=trim($_GET['sdate']); 
				//dump($sdate);die;
				//$edate=$_GET['edate'];
			    $jiequ    = substr($sdate,11,8);
			    //dump($jiequ);die;
				$zao   = trim(str_replace($jiequ,'00:00:00',$sdate));
				$wan   = trim(str_replace($jiequ,'23:59:59',$sdate));
				// dump($wan);die;
				// $tihuan2  = trim(date('Y-m-d H:i:s',strtotime($tihuan)));
				
				
				$count = M("","","DB_CONFIG1")->query("select userid,record_time record_time from t_user_everyday_record where record_time between '$zao' and '$wan' order by record_time desc");
				$counts = count($count);
				$Page       = new \Org\Bjy\Page($counts,100);
				$show       = $Page->show();
				$a = $Page->firstRow;
				$b = $Page->listRows;
				
				$deputy = M("","","DB_CONFIG1")->query("select userid,record_time record_time,name,gems,cost_gems,game_round,recharge_gems,cost_time  from t_user_everyday_record where record_time between '$zao' and '$wan'  order by record_time desc limit $a,$b");
				if($deputy)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
		}
		
		$this->assign('page',$show);
		$this->assign('deputy',$deputy);
		$this->assign('counts',$counts);
		$this->display();
	}	
	//当天代理信息
	public function active_agent()
	{
		login('您好，请先登录');
		$date1       = date("Y-m-d 0:0:0",strtotime("-1 day"));
		$date2       = date("Y-m-d 0:0:0");
		$arr1['record_time']=array('between',array($date1,$date2));
		//dump($date2);die;
		$count      = M("","t_agent_total_record","DB_CONFIG1")->where($arr1)->count();
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		
	   
		$deputy = M("","t_agent_total_record","DB_CONFIG1")->where($arr1)->select();  
		$this->assign('page',$show);
				
		if(IS_GET)
		{
			if($_GET['accounts']!="" || $_GET['name']!="" AND $_GET['sdate']=="" AND $_GET['edate']=="" )
			{
				$w['accounts']=array('like','%'.$_GET['accounts'].'%');//把数据写到空数组去  
				$w['name']=array('like','%'.$_GET['name'].'%');//把数据写到空数组去  
				$deputy=M("","t_agent_total_record","DB_CONFIG1")->where($w)->where($arr1)->select();
				if($deputy)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}	
			if($_GET['accounts']=="" AND $_GET['name']=="" AND $_GET['sdate']!="" || $_GET['edate']!="")
			{
				$sdate=$_GET['sdate']; //get来的时间转为时间戳
				$edate=$_GET['edate'];	//get来的时间转为时间戳
				$arr['record_time']=array('between',array($sdate,$edate));
				$deputy=M("","t_agent_total_record","DB_CONFIG1")->where($arr)->select();//时间不符合    需要修正！！！！
				if($deputy)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询官方给玩家冲钻记录','$state')");
				}
			}
		}
		$sum=M("","t_agent_total_record","DB_CONFIG1")->where($arr1)->count('accounts');     //代理总数、
		$this->assign('deputy',$deputy);
		$this->assign('date2',$date2);
		$this->assign('date1',$date1);
		$this->assign('sum',$sum);
		$this->display();
	}
	//当天的总信息
	public function day_information()
	{
	    login('您好，请先登录');
	    $t_users = M('','t_users','DB_CONFIG1');
		$cur_date= (date('Y-m-d H:i:s')); //现在的时间
		$cur_date1= (date('Y-m-d 00:00:00')); 	//今日凌晨
		$threeago = date('Y-m-d 00:00:00', strtotime("-3 day"));//三日前,凌晨起
		//dump($threeago);die;
		$oneago = date('Y-m-d', strtotime("-1 day"));//昨日,凌晨起
		$arr_time['create_time']=array('between',array($cur_date1,$cur_date));//今日时间段
		$arr_agent_time['regtime']=array('between',array($cur_date1,$cur_date));//今日时间段

		$wx['account']=array('like','WX%');	

		$sum_all_users=M("","t_users","DB_CONFIG1")->where($wx)->count('userid');   //玩家所有总数	
		//dump($sum_all_users);die;	
		$sum_all_agent=M("t_agent")->count('accounts');   //代理所有总数	
		$sum_users_cur=M("","t_users","DB_CONFIG1")->where($arr_time)->count('userid');  	 //查询当天新增玩家
	    $sum_agenr_cur=M("t_agent")->where($arr_agent_time)->count('accounts');  			 //查询当天新增代理
	    //dump($sum_agenr_cur);die;


        $zaixianwanjia = M("","","DB_CONFIG1")->query("CALL sp_query_online_players('$cur_date1',0,'','','',0,0);");//当前在线
        //dump($zaixianwanjia);die;
        $sum = count($zaixianwanjia);


         /*------------玩家三日留存数------------*/
		$list = M('','','DB_CONFIG1')->query("SELECT COUNT(c.userid) FROM (SELECT DISTINCT a.* FROM t_users AS a JOIN t_each_round_history AS b ON a.userid = b.userid1 WHERE  b.begin_time >= '$threeago' UNION SELECT DISTINCT a.* FROM t_users AS a JOIN t_each_round_history AS b ON a.userid = b.userid2  WHERE  b.begin_time >= '$threeago' UNION SELECT DISTINCT a.* FROM t_users AS a JOIN t_each_round_history AS b ON a.userid = b.userid3  WHERE  b.begin_time >= '$threeago' UNION SELECT  a.* FROM t_users AS a JOIN t_each_round_history AS b ON a.userid = b.userid4  WHERE  b.begin_time >= '$threeago') AS c ");
		
	    $idcount = $list[0]['count(c.userid)'];//玩家三日留存数
	    //dump($idcount);die;
	    
		$this->assign('sum_all',$sum_all);
		$this->assign('idcount',$idcount);
		$this->assign('sum_users_cur',$sum_users_cur);
		$this->assign('sum_agenr_cur',$sum_agenr_cur);
		$this->assign('sum_all_users',$sum_all_users);
		$this->assign('sum_all_agent',$sum_all_agent);
		$this->assign('sum',$sum);
		$this->display();
	}
				/* 代理商用户信息 */
	public function supervise()
	{
		login('您好，请先登录');
		$t_agent= M('','t_agent','DB_CONFIG0');
		$w=array();
		$count      = $t_agent->where($w)->where('referrer!=100')->count();
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		$loadgame=$t_agent->where('referrer!=100')->order('regtime desc')->limit($Page->firstRow.','.$Page->listRows)->select();

		//接受get数据
		$userid=$_GET['userid'];
		$name=$_GET['name'];
		$userid=$_GET['userid'];
		if(IS_GET)
		{
			if($_GET['userid']!="" || $_GET['name']!="" AND $_GET['sdate']=="" AND $_GET['edate']=="" )
			{
				$w['accounts']=array('like','%'.$userid.'%');													//把数据写到空数组去  
				$w['username']=array('like','%'.$name.'%');	//把数据写到空数组		

				$count      = $t_agent->where($w)->where('referrer!=100')->count();
				$Page       = new \Org\Bjy\Page($count,100);
				$show       = $Page->show();
				$loadgame=$t_agent->where($w,'referrer!=100')->limit($Page->firstRow.','.$Page->listRows)->select();
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理信息','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理信息','$state')");
				}
			}	
			if($_GET['userid']=="" AND $_GET['name']=="" AND $_GET['sdate']!="" || $_GET['edate']!="")
			{
				$sdate=$_GET['sdate']; 																//get来的时间转为时间戳
				$edate=$_GET['edate'];																//get来的时间转为时间戳
				$arr['regtime']=array('between',array($sdate,$edate));

				$count      = $t_agent->where($arr)->where('referrer!=100')->count();
				$Page       = new \Org\Bjy\Page($count,100);
				$show       = $Page->show();
				$loadgame=M('t_agent')->where($arr)->where('referrer!=100')->limit($Page->firstRow.','.$Page->listRows)->select();//时间不符合    需要修正！！！！
				if($loadgame)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理商信息','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理商信息','$state')");
				}				
			}
		}
		$sum=M('t_agent')->where('agencylv!=100')->count('accounts');
		$this->assign('page',$show);
		$this->assign('loadgame',$loadgame);
		$this->assign('sum',$sum);
		$this->display();
	}

	/*-------------更改代理信息--------------*/
	public function change()
	{				
		login('您好，请先登录');
		$accounts=I('get.accounts');
		$rebates=M('t_agent')->where('accounts='.$accounts)->find();
		$authority = M('t_agent')->where('agencylv=100')->find();//总权限
		//dump($authority['accounts']);die;
		
		if(IS_POST)
		{    
			$agencylv=$_POST['agencylv'];
			$names=$_POST['names'];
			$referrer=$_POST['referrer'];
			if($agencylv==0 && $referrer!=$authority['accounts']){
				error('代理等级修改为总代理时，上级必须为总公司');
			}
			if($names==""){
				error('姓名不可为空');
			}
			if($referrer==""){
				error('上级代理不可为空');
			}
			$shangji=M('t_agent')->where('accounts='.$referrer)->find();
			if($shangji!=""){
				if(M("","","DB_CONFIG0")->execute("update t_agent set agencylv='$agencylv',username='$names',referrer='$referrer' where accounts=".$accounts))
				{
					change('更改成功');
				}else{
					change('未做更改');
				}
		    }else{
		    	error('上级代理输入有误，不存在该代理');
		    }
		}
		
		$this->assign('rebates',$rebates);
		$this->display();
	}

	/*-------------删除代理--------------*/
	public function delagent()
	{				
		
		$accounts=I('get.accounts');
		$access=M('t_agent_access_config')->where('accounts_id='.$_SESSION['accounts'])->find();
		$t_agent = M('t_agent');
		//dump($access['paral']);die;
		if($access['paral'] ==1){
			$state=$t_agent->delete($accounts);
			//dump($state);die;
			if ($state){
				change('删除成功');
			}else{
				change('删除失败');
			}
		}else{
			change('您没有权限删除该代理');
		}
		
	}
	
	/*    代理转账记录    */
	public function recordpay()
	{
				login('您好，请先登录');
			$w=array('manner=2');
			$count      = M('t_agent_add_cards_to_agent')->where($w)->count();
			$Page       = new \Org\Bjy\Page($count,100);
			$show       = $Page->show();
			$presnted = M('t_agent_add_cards_to_agent')->where($w)->order('regtime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
			
			if(IS_GET)
			{
				if($_GET['userid']!="" || $_GET['name']!="" AND $_GET['sdate']=="" AND $_GET['edate']=="" )
				{
					$w['benefactor']=array('like','%'.$_GET['userid'].'%');												//把数据写到空数组去  
					$w['recipient']=array('like','%'.$_GET['name'].'%');													//把数据写到空数组	
					$count      = M('t_agent_add_cards_to_agent')->where($w)->where('manner=2')->count();
					$Page       = new \Org\Bjy\Page($count,100);
					$show       = $Page->show();	
					$presnted=M('t_agent_add_cards_to_agent')->where($w)->where('manner=2')->limit($Page->firstRow.','.$Page->listRows)->select();			
					if($presnted)
					{
						$state=0;
						$accounts=$_SESSION['accounts'];
						M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理充值记录','$state')");
					}else
					{
						$state=1;
						$accounts=$_SESSION['accounts'];
						M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理充值记录','$state')");
					}
				}	
				if($_GET['userid']=="" AND $_GET['name']=="" AND $_GET['sdate']!="" || $_GET['edate']!="")
				{
					$sdate=$_GET['sdate'];																		//get来的时间转为时间戳
					$edate=$_GET['edate'];																		//get来的时间转为时间戳
					$arr['regtime']=array('between',array($sdate,$edate));
					$count      = M('t_agent_add_cards_to_agent')->where($arr)->where('manner=2')->count();
					$Page       = new \Org\Bjy\Page($count,100);
					$show       = $Page->show();	
					$presnted=M('t_agent_add_cards_to_agent')->where($arr)->where('manner=2')->limit($Page->firstRow.','.$Page->listRows)->select();  //时间不符合    需要修正！！！！
					if($presnted)
					{
						$state=0;
						$accounts=$_SESSION['accounts'];
						M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理充值记录','$state')");
					}else
					{
						$state=1;
						$accounts=$_SESSION['accounts'];
						M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理充值记录','$state')");
					}
				}
			}
			//dump($presnted);die;
		$this->assign('page',$show);
		$this->assign('presnted',$presnted);
		$this->display();
	}
	/* 代理用户返利页面 */
	public function deduct()
	{		
				login('您好，请先登录');
		
		$deduct=M('','','DB_CONFIG0')->query("SELECT t_agent.*,t_rebate_quota.* FROM t_agent  LEFT JOIN t_rebate_quota ON t_agent.accounts=t_rebate_quota.id  WHERE   t_rebate_quota.top_limit > t_agent.rechargetotal AND t_rebate_quota.botton_limit <= t_agent.rechargetotal and t_agent.agencylv !=100");
		//dump($deduct);die;
		if(IS_GET)
		{
			if($_GET['userid']!="")
			{
				

				$deduct=M('','','DB_CONFIG0')->query("SELECT t_agent.*,t_rebate_quota.* FROM t_agent  LEFT JOIN t_rebate_quota ON t_agent.accounts=t_rebate_quota.id  WHERE   t_rebate_quota.top_limit > t_agent.rechargetotal AND t_rebate_quota.botton_limit <= t_agent.rechargetotal AND t_agent.accounts like '%".I('get.userid')."%'");
				if($deduct)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理充值记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理充值记录','$state')");
				}
			}	
			if($_GET['sdate']!="" || $_GET['edate']!="")
			{
				$sdate=$_GET['sdate'];																		//get来的时间转为时间戳
				$edate=$_GET['edate'];																		//get来的时间转为时间戳
				
				$deduct=M('','','DB_CONFIG0')->query("SELECT t_agent.*,t_rebate_quota.* FROM t_agent  LEFT JOIN t_rebate_quota ON t_agent.accounts=t_rebate_quota.id  WHERE   t_rebate_quota.top_limit > t_agent.rechargetotal AND t_rebate_quota.botton_limit <= t_agent.rechargetotal AND t_agent.regtime between '$sdate' AND '$edate'");
				if($deduct)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理充值记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理充值记录','$state')");
				}
			}
		}
		$this->assign('deduct',$deduct);
		$this->display();
	}
	/*-------------更改返利额度--------------*/
	public function rebates()
	{				
		login('您好，请先登录');
		

		$accounts=I('get.accounts');
		$rechargetotal=I('get.rechargetotal');
		$deduct=M('t_agent')->where('accounts='.$accounts)->find();
		//$sql=M("t_rebate_quota")->where('id='.$accounts)->where('top_limit >='.$rechargetotal.' AND botton_limit <='.$rechargetotal)->find();
        //dump($sql);die;
		//dump($deduct['agencylv']);die;
		if(IS_POST)
		{    
			$first=$_POST['first'];
			$second=$_POST['second'];
			$disbate=$_POST['disbate'];
			//dump($disbate);die;
            
            M("","","DB_CONFIG0")->execute("update t_rebate_quota set first_upper_rebate='$first',second_upper_rebate='$second' where id=".$accounts." AND top_limit >=".$rechargetotal." AND botton_limit <=".$rechargetotal );
            M("","","DB_CONFIG0")->execute("update t_rebate_quota set disbate='$disbate' where id=".$accounts);
            deduct('更改成功');
		}
		$this->assign('deduct',$deduct);
		$this->assign('accounts',$accounts);
		$this->assign('rechargetotal',$rechargetotal);
		$this->display();
	}
   //---------------------------配牌--------------------------
	public function guration()
	{				
		$userid=I('get.userid');
		$isconfigpai=I('get.isconfigpai');
		
		if($sql = M('','','DB_CONFIG1')->execute("update t_users set isconfigpai='$isconfigpai' where userid=".$userid)){
			gura('更改成功');
		}else{
			gura('未做更改');
		}
		
	}
	//---------------------------权限配置--------------------------
	public function purview()
	{				
		login('您好，请先登录');
		$sql = M("t_authority_configuration")->where("grade=0")->find();
		 //dump($sql);die;
		if(IS_POST)
		{    
			$searchplayer=$_POST['searchplayer'];
			if ($searchplayer=="") {
				$searchplayer = 0;
			}
			$zengs=$_POST['zengs'];
			if ($zengs=="") {
				$zengs = 0;
			}
			$creatuser=$_POST['creatuser'];
			if ($creatuser=="") {
				$creatuser = 0;
			}
			$leixing=$_POST['leixing'];
			if ($leixing=="") {
				$leixing = 0;
			}
			$shangji=$_POST['shangji'];
			if ($shangji=="") {
				$shangji = 0;
			}
			$myadmin=$_POST['myadmin'];
			if ($myadmin=="") {
				$myadmin = 0;
			}
			$myinfoxia=$_POST['myinfoxia'];
			if ($myinfoxia=="") {
				$myinfoxia = 0;
			}
			$drilling=$_POST['drilling'];
			if ($drilling=="") {
				$drilling = 0;
			}
			$agentmodi=$_POST['agentmodi'];
			if ($agentmodi=="") {
				$agentmodi = 0;
			}
			$agentcharge=$_POST['agentcharge'];
			if ($agentcharge=="") {
				$agentcharge = 0;
			}
			$buygold=$_POST['buygold'];
			if ($buygold=="") {
				$buygold = 0;
			}
			$subordinate=$_POST['subordinate'];
			if ($subordinate=="") {
				$subordinate = 0;
			}
			$policy=$_POST['policy'];
			if ($policy=="") {
				$policy = 0;
			}
			$myinfo=$_POST['myinfo'];
			if ($myinfo=="") {
				$myinfo = 0;
			}
			$setnotice=$_POST['setnotice'];
			if ($setnotice=="") {
				$setnotice = 0;
			}
			$policyedit=$_POST['policyedit'];
			if ($policyedit=="") {
				$policyedit = 0;
			}
			$payoff=$_POST['payoff'];
			if ($payoff=="") {
				$payoff = 0;
			}
			$playercharge=$_POST['playercharge'];
			if ($playercharge=="") {
				$playercharge = 0;
			}
			//dump($searchplayer);die;
			if(M('','','DB_CONFIG')->execute("update t_authority_configuration set searchplayer='$searchplayer',zengs='$zengs',creatuser='$creatuser',leixing='$leixing',zengs='$zengs',shangji='$shangji',myadmin='$myadmin',myinfoxia='$myinfoxia',drilling='$drilling',agentmodi='$agentmodi',agentcharge='$agentcharge',buygold='$buygold',subordinate='$subordinate',policy='$policy',myinfo='$myinfo',setnotice='$setnotice' ,policyedit='$policyedit',payoff='$payoff',playercharge='$playercharge' where grade=0")){
				error('更改成功');
			}else{
				error('未做更改');
			}
		}
		$this->assign('sql',$sql);
		$this->display();
	}
	//---------------------------权限配置--------------------------
	public function purview01()
	{				
		login('您好，请先登录');
		$sql = M("t_authority_configuration")->where("grade=1")->find();
		 //dump($sql);die;
		if(IS_POST)
		{    
			$searchplayer=$_POST['searchplayer'];
			if ($searchplayer=="") {
				$searchplayer = 0;
			}
			$zengs=$_POST['zengs'];
			if ($zengs=="") {
				$zengs = 0;
			}
			$creatuser=$_POST['creatuser'];
			if ($creatuser=="") {
				$creatuser = 0;
			}
			$leixing=$_POST['leixing'];
			if ($leixing=="") {
				$leixing = 0;
			}
			$shangji=$_POST['shangji'];
			if ($shangji=="") {
				$shangji = 0;
			}
			$myadmin=$_POST['myadmin'];
			if ($myadmin=="") {
				$myadmin = 0;
			}
			$myinfoxia=$_POST['myinfoxia'];
			if ($myinfoxia=="") {
				$myinfoxia = 0;
			}
			$drilling=$_POST['drilling'];
			if ($drilling=="") {
				$drilling = 0;
			}
			$agentmodi=$_POST['agentmodi'];
			if ($agentmodi=="") {
				$agentmodi = 0;
			}
			$agentcharge=$_POST['agentcharge'];
			if ($agentcharge=="") {
				$agentcharge = 0;
			}
			$buygold=$_POST['buygold'];
			if ($buygold=="") {
				$buygold = 0;
			}
			$subordinate=$_POST['subordinate'];
			if ($subordinate=="") {
				$subordinate = 0;
			}
			$policy=$_POST['policy'];
			if ($policy=="") {
				$policy = 0;
			}
			$myinfo=$_POST['myinfo'];
			if ($myinfo=="") {
				$myinfo = 0;
			}
			$setnotice=$_POST['setnotice'];
			if ($setnotice=="") {
				$setnotice = 0;
			}
			$policyedit=$_POST['policyedit'];
			if ($policyedit=="") {
				$policyedit = 0;
			}
			$payoff=$_POST['payoff'];
			if ($payoff=="") {
				$payoff = 0;
			}
			$playercharge=$_POST['playercharge'];
			if ($playercharge=="") {
				$playercharge = 0;
			}
			//dump($searchplayer);die;
			if(M('','','DB_CONFIG')->execute("update t_authority_configuration set searchplayer='$searchplayer',zengs='$zengs',creatuser='$creatuser',leixing='$leixing',zengs='$zengs',shangji='$shangji',myadmin='$myadmin',myinfoxia='$myinfoxia',drilling='$drilling',agentmodi='$agentmodi',agentcharge='$agentcharge',buygold='$buygold',subordinate='$subordinate',policy='$policy',myinfo='$myinfo',setnotice='$setnotice' ,policyedit='$policyedit',payoff='$payoff',playercharge='$playercharge' where grade=1")){
				error('更改成功');
			}else{
				error('未做更改');
			}
		}
		$this->assign('sql',$sql);
		$this->display();
	}
	//---------------------------权限配置--------------------------
	public function purview02()
	{				
		login('您好，请先登录');
		$sql = M("t_authority_configuration")->where("grade=2")->find();
		 //dump($sql);die;
		if(IS_POST)
		{    
			$searchplayer=$_POST['searchplayer'];
			if ($searchplayer=="") {
				$searchplayer = 0;
			}
			$zengs=$_POST['zengs'];
			if ($zengs=="") {
				$zengs = 0;
			}
			$creatuser=$_POST['creatuser'];
			if ($creatuser=="") {
				$creatuser = 0;
			}
			$leixing=$_POST['leixing'];
			if ($leixing=="") {
				$leixing = 0;
			}
			$shangji=$_POST['shangji'];
			if ($shangji=="") {
				$shangji = 0;
			}
			$myadmin=$_POST['myadmin'];
			if ($myadmin=="") {
				$myadmin = 0;
			}
			$myinfoxia=$_POST['myinfoxia'];
			if ($myinfoxia=="") {
				$myinfoxia = 0;
			}
			$drilling=$_POST['drilling'];
			if ($drilling=="") {
				$drilling = 0;
			}
			$agentmodi=$_POST['agentmodi'];
			if ($agentmodi=="") {
				$agentmodi = 0;
			}
			$agentcharge=$_POST['agentcharge'];
			if ($agentcharge=="") {
				$agentcharge = 0;
			}
			$buygold=$_POST['buygold'];
			if ($buygold=="") {
				$buygold = 0;
			}
			$subordinate=$_POST['subordinate'];
			if ($subordinate=="") {
				$subordinate = 0;
			}
			$policy=$_POST['policy'];
			if ($policy=="") {
				$policy = 0;
			}
			$myinfo=$_POST['myinfo'];
			if ($myinfo=="") {
				$myinfo = 0;
			}
			$setnotice=$_POST['setnotice'];
			if ($setnotice=="") {
				$setnotice = 0;
			}
			$policyedit=$_POST['policyedit'];
			if ($policyedit=="") {
				$policyedit = 0;
			}
			$payoff=$_POST['payoff'];
			if ($payoff=="") {
				$payoff = 0;
			}
			$playercharge=$_POST['playercharge'];
			if ($playercharge=="") {
				$playercharge = 0;
			}
			//dump($searchplayer);die;
			if(M('','','DB_CONFIG')->execute("update t_authority_configuration set searchplayer='$searchplayer',zengs='$zengs',creatuser='$creatuser',leixing='$leixing',zengs='$zengs',shangji='$shangji',myadmin='$myadmin',myinfoxia='$myinfoxia',drilling='$drilling',agentmodi='$agentmodi',agentcharge='$agentcharge',buygold='$buygold',subordinate='$subordinate',policy='$policy',myinfo='$myinfo',setnotice='$setnotice' ,policyedit='$policyedit',payoff='$payoff',playercharge='$playercharge' where grade=2")){
				error('更改成功');
			}else{
				error('未做更改');
			}
		}
		$this->assign('sql',$sql);
		$this->display();
	}
	//---------------------------登录用户操作日志--------------------------
	public function journal()
	{				
				login('您好，请先登录');
		$count      = M('t_journal')->count();
		$Page       = new \Org\Bjy\Page($count,100);
		$show       = $Page->show();
		$a = $Page->firstRow;
		$b = $Page->listRows;

		$sql=M("","","DB_CONFIG0")->query("select * from t_journal order by times desc limit $a, $b"); 
		if(IS_GET)
		{
			if($_GET['userid']!="" || $_GET['name']!="" AND $_GET['sdate']=="" AND $_GET['edate']=="" )
			{
				$w['action']=array('like','%'.$_GET['name'].'%');												//把数据写到空数组去  
				$w['accounts']=array('like','%'.$_GET['userid'].'%');												//把数据写到空数组去  
				$sql=M('t_journal')->where($w)->select();														//echo M('t_agent_add_cards_to_agent')->_sql();die;
				if($sql)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理操作记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理操作记录','$state')");
				}
			}	
			if($_GET['userid']=="" AND $_GET['name']=="" AND $_GET['sdate']!="" || $_GET['edate']!="")
			{
				$sdate=$_GET['sdate'];																		//get来的时间转为时间戳
				$edate=$_GET['edate'];																		//get来的时间转为时间戳
				$arr['times']=array('between',array($sdate,$edate));															//判断大于等于起始时间的条件
				$sql=M('t_journal')->where($arr)->select();  //时间不符合    需要修正！！！！				
				if($sql)
				{
					$state=0;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理操作记录','$state')");
				}else
				{
					$state=1;
					$accounts=$_SESSION['accounts'];
					M('','','DB_CONFIG0')->execute("insert into t_journal(accounts,action,state)values('$accounts','查询代理操作记录','$state')");
				}				
			}
		}
		$this->assign('sql',$sql);
		$this->assign('page',$show);
		$this->display();
	}
	//---------------------------活动专区一--------------------------
	public function activityOne()
	{	
		$list      = M('','t_activity','DB_CONFIG1')->where("id = 1")->find();
        $time = date('Y-m-d H:i:s');
		//dump($time);die;
		//record_time= '$time'
		if(IS_POST)
		{
			$title=I('post.title');
			$comment=I('post.comment');
			$is_show=I('post.is_show');
			if ($is_show =="") {
				$is_show = 0;
			}
			if ($list=="") {
				M('','','DB_CONFIG1')->execute("insert into t_activity(id,name,title,comment,is_show)
					values(1,'活动一','$title','$comment','$is_show')");
				    activityOne('更改成功');
			}else{
				if($sql = M('','','DB_CONFIG1')->execute("update t_activity set title='$title',comment='$comment',is_show='$is_show',record_time= '$time' where id=1")){
					activityOne('更改成功');
				}else{
					activityOne('未做更改');
				}
			}
		}
		$this->assign('list',$list);
		$this->display();
		
	}

	//---------------------------活动专区二--------------------------
	public function activityTwo()
	{	
		$list      = M('','t_activity','DB_CONFIG1')->where("id = 2")->find();
		$time = date('Y-m-d H:i:s');
		//dump($list);die;
		if(IS_POST)
		{
			$title=I('post.title');
			$comment=I('post.comment');
			$is_show=I('post.is_show');
			if ($is_show =="") {
				$is_show = 0;
			}
			if ($list=="") {
				M('','','DB_CONFIG1')->execute("insert into t_activity(id,name,title,comment,is_show)
					values(2,'活动二','$title','$comment','$is_show')");
				    activityTwo('更改成功');
			}else{
				if($sql = M('','','DB_CONFIG1')->execute("update t_activity set title='$title',comment='$comment',is_show='$is_show',record_time= '$time'  where id=2")){
					activityTwo('更改成功');
				}else{
					activityTwo('未做更改');
				}
			}
		}
		$this->assign('list',$list);
		$this->display();
		
	}

	//---------------------------活动专区三--------------------------
	public function activityThree()
	{	
		$list      = M('','t_activity','DB_CONFIG1')->where("id = 3")->find();
		$time = date('Y-m-d H:i:s');
		//dump($list);die;
		if(IS_POST)
		{
			$title=I('post.title');
			$comment=I('post.comment');
			$is_show=I('post.is_show');
			if ($is_show =="") {
				$is_show = 0;
			}
			if ($list=="") {
				M('','','DB_CONFIG1')->execute("insert into t_activity(id,name,title,comment,is_show)
					values(3,'活动三','$title','$comment','$is_show')");
				    activityThree('更改成功');
			}else{
				if($sql = M('','','DB_CONFIG1')->execute("update t_activity set title='$title',comment='$comment',is_show='$is_show',record_time= '$time'  where id=3")){
					activityThree('更改成功');
				}else{
					activityThree('未做更改');
				}
			}
		}
		$this->assign('list',$list);
		$this->display();
		
	}

    //---------------------------活动专区四--------------------------
	public function activityFour()
	{	
		$list      = M('','t_activity','DB_CONFIG1')->where("id = 4")->find();
		$time = date('Y-m-d H:i:s');
		//dump($list);die;
		if(IS_POST)
		{
			$title=I('post.title');
			$comment=I('post.comment');
			$is_show=I('post.is_show');
			if ($is_show =="") {
				$is_show = 0;
			}
			//dump($is_show);die;

			if ($list=="") {
				M('','','DB_CONFIG1')->execute("insert into t_activity(id,name,title,comment,is_show)
					values(4,'活动四','$title','$comment','$is_show')");
				    activityFour('更改成功');
			}else{
				if($sql = M('','','DB_CONFIG1')->execute("update t_activity set title='$title',comment='$comment',is_show='$is_show',record_time= '$time'  where id=4")){
					activityFour('更改成功');
				}else{
					activityFour('未做更改');
				}
			}
		}
		$this->assign('list',$list);
		$this->display();
		
	}

	
}





































































